<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />


                  <div class="right-form"  <c:if test="${not empty parentMenu && '1' eq parentMenu.status }"> disabled='disabled'</c:if> >
                        <form action="" onsubmit="return false;" id="menuForm">
                            <ul>
                                <li style="padding-bottom:10px;width:70%;" >
                                    <label class="ser-label">菜单级别：</label>
                                    <div class="form-content clearfix" style="padding-left: 150px;">
                                        <span class="mr5">ROOT</span>
                                        &gt;&gt;
                                        <c:if test="${not empty parentMenuList }">
                                        	<c:forEach items = "${parentMenuList }" var="p">
                                        	<span class="mr5">${p.name }</span>&gt;&gt;
                                        	</c:forEach>
                                        </c:if>
                                        <span class="text-red ml10">${menu.name }</span>
                                    </div>
                                </li>
                                
                                <li class="w-per">
                                <input type="hidden" value="${menu.id }" id="s_menuId" />
                                <input type="hidden" value="${menu.parentMenuId}" id="s_parentMenuId" />
                                    <label class="ser-label"><em class="text-red mr5">*</em>菜单名称：</label>
                                    <div class="form-content">
                                    	<input class="inputText" id="s_menuName" name="menuName" value="${menu.name }" type="text">
                                    	<div class="form-tips text-red" ></div>
                                        
                                    </div>
                                </li>
                                <li class="w-per">
                                    <label class="ser-label">请求地址：</label>
                                    <div class="form-content">
                                    	<input class="inputText" id="s_menuUrl" name="menuUrl" value="${menu.menuUrl }" type="text">
                                    	<div class="form-tips text-red" ></div>
                                    </div>
                                </li>
                                <li class="w-per">
                                    <label class="ser-label"><em class="text-red mr5">*</em>同级排序：</label>
                                    <div class="form-content">
                                    	<input class="inputText" id="s_orderNum" name="orderNum" value="${menu.orderNum }" type="text" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9]+/,'');}).call(this)" onblur="this.v();">
                                    	<div class="form-tips text-red" ></div>
                                    </div>
                                </li>
                                <li class="w-per">
                                    <label class="ser-label"><em class="text-red mr5">*</em>菜单状态：</label>
                                    <div class="form-content">
                                        <select class="form-control-select" id="s_menuStatus" name="menuStatus" <c:if test="${not empty menu.id }"> disabled='disabled' </c:if> >
                                        	<option value='' >请选择</option>
                                        	<c:choose>
                                        		<c:when test="${'1' eq menu.status }">
                                        			<option value="0">正常</option>
                                            		<option value="1" selected="selected">停用</option>
                                        		</c:when>
                                        		<c:when test="${'0' eq menu.status }">
                                        			<option value="0" selected="selected" >正常</option>
                                            		<option value="1">停用</option>
                                        		</c:when>
                                        		<c:otherwise>
                                        			<option value="0">正常</option>
                                            		<option value="1">停用</option>
                                        		</c:otherwise>
                                        	</c:choose>
                                            
                                        </select>
                                       <div class="form-tips text-red" ></div>
                                    </div>
                                </li>
                                <li class="w-per pb10">
                                    <label class="ser-label">&nbsp;</label>
                                    <div class="form-content">
                                    <c:if test="${ empty parentMenu || '0' eq parentMenu.status }">
                                    <c:if test="${not empty menu.id }" >
                                        <c:if test="${'0' eq menu.status }">
                                        <shiro:hasPermission name="common-service-menu:stop">
                                          <button class="btn btn-red" onclick="stopMenu('${menu.id }')"><i class="fa fa-ban mr5"></i>停用</button>
                                        </shiro:hasPermission>
                                        </c:if>
                                        <c:if test="${'1' eq menu.status }">
                                        <shiro:hasPermission name="common-service-menu:start">
                                        <button class="btn btn-green" onclick="openMenu('${menu.id }')"><i class="fa fa-check-circle-o mr5"></i>启用</button>
                                        </shiro:hasPermission>
                                        </c:if>
                                        <shiro:hasPermission name="common-service-menu:delete">
                                        <button class="btn btn-default" onclick="deleteMenu('${menu.id}')"><i class="fa fa-times mr5"></i>删除</button>
                                       </shiro:hasPermission>
                                       <shiro:hasPermission name="common-service-menu:add">
                                        <button class="btn btn-default" onclick="addSameLevel('${menu.id }','${menu.parentMenuId }')"><i class="fa fa-plus mr5"></i>增加同级</button>
                                        <button class="btn btn-default" onclick="addNextLevel('${menu.id}')"><i class="fa fa-plus mr5"></i>增加下级</button>
                                      </shiro:hasPermission>
                                     </c:if>  
                                     <shiro:hasPermission name="common-service-menu:add">
                                        <button class="btn btn-orange" onclick="saveMenu()"><i class="fa fa-save mr5"></i>保存</button>
                                      </shiro:hasPermission>
                                        <c:if test="${not empty backMenuId }">
                                        <button class="btn btn-default" onclick="selectedMenu('${backMenuId}')"><i class="fa fa-times mr5"></i>取消</button>
                                        </c:if>
                                        
                                        </c:if>
                                    </div>
                                </li>
                                
                            </ul>
                        </form>
                	</div>
                	
<script src="${ctx}/static/js/jquery.validate.min.js?_v=${menu.appId}" type="text/javascript"></script>
<%-- <script src="${ctx}/static/js/jquery.extend.validate.js?_v=${menu.appId}" type="text/javascript"></script> --%>
<script src="${ctx}/static/js/iam-util.js?_v=${menu.appId}" type="text/javascript"></script>
                	
                	
 <script type="text/javascript">
 $("#menuForm").validate({
	onkeyup: false,
	onsubmit: false,
	onfocusout : function(element){
		$(element).valid();
	},
	rules : {
		menuName:{
			required : true,
			stringCheckIAM: true,
			maxlength:30
		},
		menuUrl : {
			
			maxlength:100,
			iamUrl: true 
		},
		orderNum : {
			maxlength:5,
			required : true
		},
		menuStatus :{
			required: true
		}
	},
	messages : {
		menuName : {
			required : "请完善必填信息",
			stringCheckIAM:"请输入正确的菜单名称",
			maxlength: "请输入正确的菜单名称"
		},
		menuUrl:{
			maxlength:"请输入正确的请求地址",
			iamUrl: "请输入正确的请求地址"
		},
		orderNum : {
			required : "请完善必填信息",
			maxlength:"请输入正确的同级排序"
			
		},
		menuStatus :{
			required: "请完善必填信息"
		}
	},
	errorPlacement: function(error, element) {
		 if(error){    //error存在的时候
			 $(element).next("div").html(error); //showMsg为你自定义的信息显示区域的id。
			
		 }                            //这里的element是录入数据的对象  
		 $(element).addClass('input-danger');
		 
	 },
	 success:function(label){
		 $(label).parent().prev('.input-danger').removeClass('input-danger');
		 $(label).remove();
	 }
});
 </script>